home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / CONFIG.C < prev    next >
Text File  |  1990-11-12  |  11KB  |  455 lines

  1. /* XBBS Message Base Reader -- This module parses the control file */
  2.  
  3. #include "msgg.h"
  4. #include "twindow.h"
  5. #include "keys.h"
  6. #include "headedit.h"
  7.  
  8.  
  9.  
  10. void pascal read_control (char *file,char *application) {
  11.  
  12.     struct nodeidx huge *nidxx=NULL;
  13.     int pf;
  14.     static char s[256];
  15.     char *p;
  16.     char *pp;
  17.     struct ffblk f;
  18.     char nonodelist=0;
  19.     char nomouse=0;
  20.     long x;
  21.  
  22.     for(x=0;x<10;x++) fkey[(word)x]=NULL;
  23.  
  24.     if(!strchr(file,'\\') && !strchr(file,':') && !strchr(file,'/')) {
  25.         p=searchpath(file);
  26.         file=p;
  27.     }
  28.  
  29.     if(!(pf=_open(file,O_RDONLY | O_DENYNONE | O_TEXT))==-1) {
  30.         error_message(" Can't open ctl file ");
  31.         pause();
  32.         exit(3);
  33.     }
  34.     fputs("\nParsing config file...",stderr);
  35.  
  36.     if(*application && application) {
  37.         while (!eof(pf)) {
  38.             getone(s,pf);
  39.             if (!*s) continue;
  40.             p=strtok(s," ");
  41.             strupr(p);
  42.             pp=strtok(0,"\n");
  43.             if (pp==NULL) pp="";
  44.             strip(pp,98);
  45.             stripcr(p);
  46.             if(!stricmp(p,"APPLICATION")) {
  47.                 if(!stricmp(pp,application)) break;
  48.             }
  49.         }
  50.     }
  51.     if(eof(pf)) {
  52.         error_message(" APPLICATION statement not matched or empty file ");
  53.         pause();
  54.         exit(3);
  55.     }
  56.  
  57.     while (!eof(pf)) {
  58.         getone(s,pf);
  59.         if (!*s) continue;
  60.         p=strtok(s," ");
  61.         pp=strtok(0,"\n");
  62.         if (pp==NULL) pp="";
  63.         strip(pp,98);
  64.         stripcr(p);
  65.  
  66. #ifdef DEBUG
  67.  
  68.         printf("\n`%s' -> `%s'",p,pp);
  69.  
  70. #endif
  71.  
  72.         if(!stricmp(p,"SPAWNVIEW")) {
  73.             strip(pp,79);
  74.             if(spawnview) free(spawnview);
  75.             spawnview=strdup(pp);
  76.         }
  77.         else if(!stricmp(p,"FLSEARCH")) {
  78.             strip(pp,79);
  79.             if(flsearch)free(flsearch);
  80.             flsearch=strdup(pp);
  81.         }
  82.         else if(!stricmp(p,"ENDAPP")) break;
  83.         else if (!stricmp(p,"ADDRESS") && noaddress<(char)(max(maxy,25)-2)) {
  84.             strip(pp,27);
  85.             pp=strtok(pp,":");
  86.             address[noaddress]=(struct _address *)malloc(sizeof(struct _address));
  87.             if (address[noaddress]==NULL) {
  88.                 fputs("\nOOM for addresses\n",stdout);
  89.             }
  90.             else {
  91.                 address[noaddress]->zone=(word)atol(pp);
  92.                 address[noaddress]->net=(word)atol(strtok(0,"/"));
  93.                 address[noaddress]->node=(word)atol(strtok(0,"."));
  94.                 address[noaddress]->point=(word)atol(strtok(0,"@"));
  95.                 p=strtok(0,"\n");
  96.                 strncpy(address[noaddress]->domain,p,37);
  97.                 address[noaddress]->domain[36]=0;
  98.                 noaddress++;
  99.             }
  100.         }
  101.         else if(!stricmp(p,"FKEY")) {
  102.  
  103.             int temp;
  104.  
  105.             temp=atoi(strtok(pp," "));
  106.             pp=strtok(0,"\n");
  107.             lstrip(pp);
  108.             if(pp!=NULL && *pp && temp>0 && temp<11) {
  109.                 if(fkey[temp-1])free(fkey[temp-1]);
  110.                 fkey[temp-1]=(char *)malloc(strlen(pp)+1);
  111.                 if(!fkey[temp-1]) continue;
  112.                 strcpy(fkey[temp-1],pp);
  113.             }
  114.         }
  115.         else if(!stricmp(p,"VMODE")) {
  116.             videomethod=atoi(pp);
  117.         }
  118.         else if(!stricmp(p,"HEIGHT")) {
  119.             maxy=atoi(pp);
  120.         }
  121.         else if(!stricmp(p,"WIDTH")) {
  122.             maxx=atoi(pp);
  123.         }
  124.         else if(!stricmp(p,"NOMOUSE")) {
  125.             nomouse=1;
  126.         }
  127.         if (!stricmp(p,"NOHILITE")) {
  128.             hilite=1;
  129.         }
  130.         else if (!stricmp(p,"TEMPLATE")) {
  131.             strip(pp,79);
  132.             if(template)free(template);
  133.             template=strdup(pp);
  134.         }
  135.         else if (!stricmp(p,"TEXTEDITOR")) {
  136.             if(texteditor) free(texteditor);
  137.             texteditor=strdup(pp);
  138.         }
  139.         else if (!stricmp(p,"USEDEFAULT")) {
  140.             usedefault=1;
  141.         }
  142.         else if (!stricmp(p,"MAKEINFO")) {
  143.             makeinfo=1;
  144.         }
  145.         else if (!stricmp(p,"NO*PT")) {
  146.             nopt=1;
  147.         }
  148.         else if (!stricmp(p,"NOINTL")) {
  149.             nointl=1;
  150.         }
  151.         else if (!stricmp(p,"NOCHECK")) {
  152.             autocheck=0;
  153.         }
  154.         else if (!stricmp(p,"COMPRESS")) {
  155.             packsize=(word)atol(pp);
  156.             if(packsize<1024)packsize=1024;
  157.         }
  158.         else if(!stricmp(p,"NOTRACK")) {
  159.             notrack=1;
  160.         }
  161.         else if(!stricmp(p,"NETBOARD")) {
  162.             netboard=(word)atol(pp);
  163.             if(netboard>4095)netboard=0;
  164.         }
  165.         else if(!stricmp(p,"ALTBOARD")) {
  166.             altboard=(word)atol(pp);
  167.             if(altboard>4095)altboard=0;
  168.         }
  169.         else if(!stricmp(p,"TOTALAREAS")) {
  170.             totalareas=(word)atol(pp);
  171.             printf("\nTracking LMRs for %u areas",totalareas);
  172.         }
  173.         else if(!stricmp(p,"USERNUMBER")) {
  174.             userno=(word)atol(pp);
  175.         }
  176.         else if (!stricmp(p,"START")) {
  177.             areano=(word)atol(pp);
  178.             if (areano<1 || areano>4095) areano=0;
  179.         }
  180.         else if (!stricmp(p,"WRAP")) {
  181.             if(wrapcall) free(wrapcall);
  182.             wrapcall=strdup(pp);
  183.         }
  184.         else if (!stricmp(p,"LINES")) {
  185.             maxlines=(word)atol(pp);
  186.             if (maxlines<257) maxlines=257;
  187.         }
  188.         else if (!stricmp(p,"BEFOREQUOTE")) {
  189.             strip(pp,79);
  190.             if(before_quote) free(before_quote);
  191.             before_quote=strdup(pp);
  192.         }
  193.         else if (!stricmp(p,"AFTERBEFORE")) {
  194.             strip(pp,79);
  195.             if(after_before) free(after_before);
  196.             after_before=strdup(pp);
  197.         }
  198.         else if (!stricmp(p,"AFTERQUOTE")) {
  199.             strip(pp,79);
  200.             if(after_quote) free(after_quote);
  201.             after_quote=strdup(pp);
  202.         }
  203.         else if (!stricmp(p,"NONODELIST")) {
  204.             nonodelist=1;
  205.         }
  206.         else if (!stricmp(p,"EDITOR")) {
  207.             if(editor)free(editor);
  208.             editor=strdup(pp);
  209.         }
  210.         else if (!stricmp(p,"ANSIEDITOR")) {
  211.             if(ansieditor)free(ansieditor);
  212.             ansieditor=strdup(pp);
  213.         }
  214.         else if (!stricmp(p,"NODELIST")) {
  215.             strip(pp,78);
  216.             if(nodepath)free(nodepath);
  217.             nodepath=strdup(pp);
  218.         }
  219.         else if (!stricmp(p,"PAGELENGTH")) {
  220.             pagelength=(char)atoi(pp);
  221.         }
  222.         else if (!stricmp(p,"TOPMARGIN")) {
  223.             topmargin=(char)atoi(pp);
  224.         }
  225.         else if (!stricmp(p,"BOTTOMMARGIN")) {
  226.             bottommargin=(char)atoi(pp);
  227.         }
  228.         else if (!stricmp(p,"LEFTMARGIN")) {
  229.             leftmargin=(char)atoi(pp);
  230.         }
  231.         else if (!stricmp(p,"TEXTWIDTH")) {
  232.             textwidth=(char)atoi(pp);
  233.         }
  234.         else if (!stricmp(p,"BEFOREHEADER")) {
  235.             strip(pp,11);
  236.             while ((p=strchr(pp,'~'))) *p='\x1b';
  237.             while ((p=strchr(pp,'`'))) *p='\n';
  238.             strcpy(beforeheader,pp);
  239.         }
  240.         else if (!stricmp(p,"AFTERTEXT")) {
  241.             strip(pp,47);
  242.             while ((p=strchr(pp,'~'))) *p='\x1b';
  243.             while ((p=strchr(pp,'`'))) *p='\n';
  244.             strcpy(aftertext,pp);
  245.         }
  246.         else if (!stricmp(p,"AFTERHEADER")) {
  247.             strip(pp,11);
  248.             while ((p=strchr(pp,'~'))) *p='\x1b';
  249.             while ((p=strchr(pp,'`'))) *p='\n';
  250.             strcpy(afterheader,pp);
  251.         }
  252.         else if (!stricmp(p,"AFTERPRINTING")) {
  253.             strip(pp,11);
  254.             while ((p=strchr(pp,'~'))) *p='\x1b';
  255.             while ((p=strchr(pp,'`'))) *p='\n';
  256.             strcpy(afterprinting,pp);
  257.         }
  258.         else if (!stricmp(p,"ALIAS") && noalias<(char)(max(maxy,25)-2)) {
  259.             strip(pp,35);
  260.             if(noalias) for(x=0;x<noalias;x++) {
  261.                 if(!stricmp(pp,alias[(word)x])) goto BreakOut;
  262.             }
  263.             alias[noalias]=(char *)malloc(36);
  264.             if (alias[noalias]==NULL) {
  265.                 fputs("\nOOM for aliases\n",stdout);
  266.             }
  267.             else {
  268.                 strcpy(alias[noalias],pp);
  269.                 noalias++;
  270.             }
  271. BreakOut:
  272. ;
  273.         }
  274.         else if (!stricmp(p,"ATTRIBUTES")) defaultattr=(word)atol(pp);
  275.         else if (!stricmp(p,"EXPORTNAME")) {
  276.             strip(pp,65);
  277.             strcpy(filenamer,pp);
  278.         }
  279.         else if (!stricmp(p,"PATH") && nodirs<(char)(max(maxy,25)-2)) {
  280.             strip(pp,78);
  281.             if(nodirs) for(x=0;x<nodirs;x++) {
  282.                 if(!stricmp(pp,dirs[(word)x])) goto BreakOut2;
  283.             }
  284.             dirs[nodirs]=(char *)malloc(79);
  285.             if(dirs[nodirs]==NULL) {
  286.                 fputs("\nOOM for paths\n",stdout);
  287.             }
  288.             else {
  289.                 if(!*pp) dirs[nodirs]=0;
  290.                 strcpy(dirs[nodirs],pp);
  291.                 nodirs++;
  292.             }
  293. BreakOut2:
  294. ;
  295.         }
  296.         else if (!stricmp(p,"USEEMS")) {
  297.             LIMEMS=1;
  298.         }
  299.         else if (!stricmp(p,"SWAP")) {
  300.             swap=1;
  301.         }
  302.         else if (!stricmp(p,"SWAPDRIVE")) {
  303.             useswapdisk=toupper(*pp);
  304.         }
  305.         else if (!stricmp(p,"SWAPFILE")) {
  306.             strip(pp,63);
  307.             strcpy(swapname,pp);
  308.         }
  309.         if (!stricmp(p,"TEXTCOLOR")) readtextcolor=(char)atoi(pp);
  310.         else if (!stricmp(p,"TEXTBACK")) readtextback=(char)atoi(pp);
  311.         else if (!stricmp(p,"STATCOLOR")) readstatcolor=(char)atoi(pp);
  312.         else if (!stricmp(p,"STATBACK")) readstatback=(char)atoi(pp);
  313.         else if (!stricmp(p,"HEADCOLOR")) readheadcolor=(char)atoi(pp);
  314.         else if (!stricmp(p,"HEADBACK")) readheadback=(char)atoi(pp);
  315.         else if (!stricmp(p,"ORIGFORE")) orig_fore=(char)atoi(pp);
  316.         else if (!stricmp(p,"ORIGBACK")) orig_back=(char)atoi(pp);
  317.         else if (!stricmp(p,"TEARFORE")) tear_fore=(char)atoi(pp);
  318.         else if (!stricmp(p,"TEARBACK")) tear_back=(char)atoi(pp);
  319.         else if (!stricmp(p,"QUOTEFORE")) quote_fore=(char)atoi(pp);
  320.         else if (!stricmp(p,"QU